<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ page import="java.util.List"%>
<%@ page import="org.dualr.litelog.entity.Post"%>
<%@ page import="org.dualr.litelog.entity.Page"%>
<%@ page import="org.dualr.litelog.entity.Category"%>
<%@ page import="org.dualr.litelog.dao.CategoryDao"%>
<%@ page import="org.dualr.litelog.utils.LiteLogUtil"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Posts - LiteLog Administration</title>
<link href="../admin/common.css" rel="stylesheet" type="text/css" media="screen"/>
</head>
<body>
<h1>文档管理</h1>
<div>
<table class="data-list" width="100%" cellspacing="0" cellpadding="0">
	<tr class="caption">
	<td width="28">序号</td>
	<td>标题</td>
	<td>类别</td>
	<td>评论数</td>
	<td>点击数</td>
	<td>状态</td>
	<td>评论状态</td>
	<td>日期</td>
	<td>查看</td>
	<td>编辑</td>
	<td>删除</td>
	</tr>
	<%
		List<Post> postList = (List<Post>)request.getAttribute("PostList");
		if (postList.size() != 0 ){
			int i =1;
			for(Post post : postList){
	%>
	<tr>
		<td ><%=i++%></td>
		<td ><a href="post?method=view&id=<%=post.getId()%>" target="_blank"><%=post.getTitle()%></a></td>
		<td>
			<%
				List<Category> categoryList = CategoryDao.getInstance().getListByProperty("type","post","string");
						for(Category category : categoryList){
							if(post.getCategoryId() == category.getId()){
								out.print(category.getName());
							}
						}
			%>
		</td>
		<td><%=post.getCommentCount()%></td>
		<td><%=post.getHits()%></td>
		<td><%=post.getStatus()%></td>
		<td><%=post.getCommentStatus()%></td>
		<td width="70"><%=LiteLogUtil.getInstance().formateDate(post.getPostDate(), "yyyy-MM-dd")%></td>
		<td width="30"><a href="post?method=view&id=<%=post.getId()%>" target="_blank">查看</a></td>
		<td width="30"><a href="admin/editPost.jsp?id=<%=post.getId()%>">编辑</a></td>
		<td width="30"><a href="admin?entity=post&option=delete&id=<%=post.getId()%>&categoryId=<%=post.getCategoryId()%>">删除</a></td>
	</tr>
		<%
			}
			Page pages = (Page)request.getAttribute("Page");
			%>
			<tr>
				<td colspan="11" id="page">
				记录数:<%=pages.getHits()%> [<a href="admin?entity=post&option=list&page=<%=pages.getPrevPage()%>">上一页</a>]<%=pages.getCurPage()%>/<%=pages.getPageNum()%>[<a href="admin?entity=post&option=list&page=<%=pages.getNextPage()%>">下一页</a>]
				</td>
			</tr>
			<%
		}else{
			%>
			<tr>
				<td colspan="11">列表为空</td>
			</tr>
			<%
		}
	%>
</table>
</div>
</body>
</html>